const values_default = {}

const domain_default = {}

const fields_default = {
  name: null,
  display_name: null,
  date: null,
  partner_id: null,
  state_id: null,
  country_id: null,
  item_id: null,
  value: null
}

const filterItems = [
  { type: 'date', name: 'date', placeholder: '时间' },
  { type: 'select', name: 'country_id', placeholder: '国家' },
  {
    type: 'select',
    name: 'partner_id',
    placeholder: '农户',
    options: {
      fields: { country_id: null, state_id: null },
      domain: {
        company_registry: 'soil',
        comment___like: 'customer'
      }
    },
    options_for_select: params => {
      const { domain, options_for_select } = params
      return options_for_select.filter(item => {
        if (domain.country_id) {
          return item.country_id === domain.country_id
        } else {
          return true
        }
      })
    }
  },

  { type: 'select', name: 'item_id', placeholder: '检测项目' }
]

const columns = [
  { name: 'date', type: 'char', label: '日期' },
  { name: 'partner_id__name', type: 'char', label: '农户' },
  { name: 'state_id__name', type: 'char', label: '州/省' },
  { name: 'country_id__name', type: 'char', label: '国家' },
  { name: 'item_id__name', type: 'char', label: '检测项目' },
  { name: 'value', type: 'char', label: '数值' }
]

const Model = {
  // name: 'res.partner',
  configs: {
    values_default,
    domain_default,
    fields_default,
    filterItems,
    columns
  },

  extend: BaseClass => {
    class ModelClass extends BaseClass {
      global_domain(domain_src = {}) {
        const domain = { ...domain_src }
        return super.global_domain(domain)
      }
    }
    return ModelClass
  }
}

export default Model
